﻿using AnyLink.Domain.Enums;
using Newtonsoft.Json;
using SqlSugar;

namespace AnyLink.Domain.Entities.System
{
    /// <summary>
    /// 用户信息表
    /// </summary>
    [SugarTable("sys_user", TableDescription = "用户信息表", IsDisabledUpdateAll = true)]
    public class SysUser : BaseAuditedEntity<long>
    {
        /// <summary>
        /// 用户ID
        /// </summary>
        [SugarColumn(ColumnName = "user_id", IsPrimaryKey = true, ColumnDescription = "用户ID")]
        [JsonProperty(propertyName: "userId")]
        public override long Id { get; set; }

        /// <summary>
        /// 部门ID
        /// </summary>
        [SugarColumn(ColumnName = "dept_id", ColumnDescription = "部门ID", IsNullable = true)]
        public long? DeptId { get; set; }

        /// <summary>
        /// 登录账号
        /// </summary>
        [SugarColumn(ColumnName = "login_name", ColumnDataType = "VARCHAR(30)", ColumnDescription = "登录账号", IsNullable = true)]
        public string LoginName { get; set; }

        /// <summary>
        /// 用户昵称
        /// </summary>
        [SugarColumn(ColumnName = "user_name", ColumnDataType = "VARCHAR(30)", ColumnDescription = "用户昵称", IsNullable = true)]
        public string UserName { get; set; }

        /// <summary>
        /// 用户类型（00系统用户 01注册用户）
        /// </summary>
        [SugarColumn(ColumnName = "user_type", ColumnDataType = "VARCHAR(2)", ColumnDescription = "用户类型（00系统用户 01注册用户）", IsNullable = true)]
        public string UserType { get; set; }

        /// <summary>
        /// 用户邮箱
        /// </summary>
        [SugarColumn(ColumnName = "email", ColumnDataType = "VARCHAR(50)", ColumnDescription = "用户邮箱", IsNullable = true)]
        public string Email { get; set; }

        /// <summary>
        /// 手机号码
        /// </summary>
        [SugarColumn(ColumnName = "phonenumber", ColumnDataType = "VARCHAR(11)", ColumnDescription = "手机号码", IsNullable = true)]
        public string Phonenumber { get; set; }

        /// <summary>
        /// 用户性别（0男 1女 2未知）
        /// </summary>
        [SugarColumn(ColumnName = "sex", ColumnDescription = "用户性别（0男 1女 2未知）", IsNullable = true,Length =1)]
        public SexEnum Sex { get; set; }

        /// <summary>
        /// 头像路径
        /// </summary>
        [SugarColumn(ColumnName = "avatar", ColumnDataType = "VARCHAR(100)", ColumnDescription = "头像路径", IsNullable = true)]
        public string Avatar { get; set; }

        /// <summary>
        /// 密码
        /// </summary>
        [SugarColumn(ColumnName = "password", ColumnDataType = "VARCHAR(50)", ColumnDescription = "密码", IsNullable = true)]
        public string Password { get; set; }

        /// <summary>
        /// 盐加密
        /// </summary>
        [SugarColumn(ColumnName = "salt", ColumnDataType = "VARCHAR(20)", ColumnDescription = "盐加密", IsNullable = true)]
        public string Salt { get; set; }

        /// <summary>
        /// 帐号状态（0正常 1停用）
        /// </summary>
        [SugarColumn(ColumnName = "status", ColumnDescription = "帐号状态（0正常 1停用）", IsNullable = true,Length =1)]
        public StatusEnum Status { get; set; }

        /// <summary>
        /// 删除标志（0代表存在 2代表删除）
        /// </summary>
        [SugarColumn(ColumnName = "del_flag", ColumnDescription = "删除标志（0代表存在 2代表删除）", IsNullable = true, Length = 1)]
        public DelFlagEnum DelFlag { get; set; }

        /// <summary>
        /// 最后登录IP
        /// </summary>
        [SugarColumn(ColumnName = "login_ip", ColumnDataType = "VARCHAR(128)", ColumnDescription = "最后登录IP", IsNullable = true)]
        public string LoginIp { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        [SugarColumn(ColumnName = "login_date", ColumnDescription = "最后登录时间", IsNullable = true)]
        public DateTime LoginDate { get; set; }

        /// <summary>
        /// 密码最后更新时间
        /// </summary>
        [SugarColumn(ColumnName = "pwd_update_date", ColumnDescription = "密码最后更新时间", IsNullable = true)]
        public DateTime PwdUpdateDate { get; set; }        

        /// <summary>
        /// 备注
        /// </summary>
        [SugarColumn(ColumnName = "remark", ColumnDataType = "VARCHAR(500)", ColumnDescription = "备注", IsNullable = true)]
        public string Remark { get; set; }
    }
}